﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils.Menu;
using System.Collections;
using DevExpress.XtraGrid.Localization;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Columns;


namespace NNLInterface
{
    public partial class frmBaseBasicM : NNLInterface.frmBaseToolXC
    {
        
        public DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit repselCheck
        {
            get
            {
                return this.repCheck;
            }
            set
            {
                if (this.repCheck == value)
                    return;
                repCheck = value;
            }
        }

        public frmBaseBasicM()
        {
            InitializeComponent();
        
            //设定皮肤风格
            int i = 0;
            foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)
            {
                DevExpress.XtraBars.BarButtonItem itemStyle = new DevExpress.XtraBars.BarButtonItem();
                itemStyle.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(itemStyle_ItemClick);
                itemStyle.Caption = skin.SkinName;
                itemStyle.Tag = i;
                this.BarStyle.AddItem(itemStyle);
                i++;
            }

            this.ListGrid.MenuManager = this.barmanager;
        }

        private void ListView_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e)
        {
            if (common._userid != "admin")
            {
                if (e.MenuType == GridMenuType.Column)
                    foreach (DXMenuItem item in e.Menu.Items)
                    {
                        if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnColumnCustomization))
                        {
                            item.Visible = false;
                        }

                        if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnRemoveColumn))
                        {
                            item.Visible = false;
                        }

                        if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuGroupPanelHide))
                        {
                            item.Visible = false;
                        }

                        if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuGroupPanelShow))
                        {
                            item.Visible = false;
                        }

                        if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnGroupBox))
                        {
                            item.Visible = false;
                        }

                        if (item.Caption == GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnGroup))
                        {
                            item.Visible = false;
                        }


                    }
            }
        }

        private void ListViewDetail_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e)
        {

        }

        //皮肤切换
        void itemStyle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(DevExpress.Skins.SkinManager.Default.Skins[(int)e.Item.Tag].SkinName);
            common.sysParameter.formskin = (common.FormSkin)((int)e.Item.Tag);

        }

    }
}
